<%@ page language="java"
	import="java.util.*,com.jy.modules.common.util.ObtainPropertiesInfo"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib uri="/app" prefix="app"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
if(request.getServerPort() == 80){
	basePath = request.getScheme()+"://"+request.getServerName()+path+"/";
}
%>
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><%=ObtainPropertiesInfo.getValByKey("app.name") %></title>
<jsp:include page="/common/StaticJavascript.jsp" />
<link rel="stylesheet" href="<%=basePath%>css/home/home.css">
<script type="text/javascript">
	function openUrl(url){
		var f=document.getElementById("mainFrame");
		f.src=url;
	}
</script>

</head>

<body>
	<div class="top">
		<div class="logo"></div>
		<div class="sysName">
			<%=ObtainPropertiesInfo.getValByKey("app.name") %>
		</div>
		<div class="loginInfo">
			<ul>

				<li><a
					href="<%=ObtainPropertiesInfo.getValByKey("cas.logout.url") %>">退出</a></li>
				<li class="liSplit"></li>
				<li><a
					href="<%=ObtainPropertiesInfo.getValByKey("cas.modifypwd.url") %>?username=<shiro:principal/>"
					target="_blank">修改密码</a></li>
				<li class="liSplit"></li>
				<li><a href="#"
					onclick="triggerMenu('/sysMessagecenter/prepareExecute/toQueryPage')">消息(<span
						id="user_message_count"></span>)
				</a></li>
				<li class="liSplit"></li>

				<%-- <li><a href="https://cas.jypt.com:8443/cas/logout?service=<%=basePath%>">退出</a></li> --%>

				<li><shiro:principal property="name"/></li>
			</ul>

		</div>
	</div>
	<div class="content">
		<div class="leftMenu" id="leftMenu"></div>
		<div class="moveLeft" id="moveLeft">
			<div class="shrinkIcon" id="shrinkIcon"></div>
		</div>
		<div class="mainDiv" id="mainDiv" name="mainDiv">
			<!-- <iframe width="100%" height="100%" style="border:0px; margin:0px;padding:0px;" id="mainFrame"></iframe> -->
		</div>
	</div>

	<div id="mask" class="maskDiv"></div>
<script type="text/javascript">
	window.onload=function(){
		//var menus=[]; 
		 
		jyAjax("<app:contextPath/>/sysMenu/querySysMenuForHome","&sortName=id&sortType=asc",function(result){
			var maps={};
			var datas=[];
			if(result&&result.data&&result.data.length){
				for(var i=0;i<result.data.length;i++){
					var data=result.data[i];
					data["text"]=data["menuName"];
					if(data["menuUrl"] != null && data["menuUrl"] != ""  && data["menuUrl"] != "null"){
						data["url"]="<%=basePath%>"+data["menuUrl"];
					}
					
					if(i==0){
						datas.push(data);
					}else{
						if(maps[data.parentId]){
							var d=maps[data.parentId];
							if(!d["subNodes"]){
								d["subNodes"]=[];
							}
							d["subNodes"].push(data);
						}else{
							datas.push(data);
						}
					}
					maps[data.id]=data;
				}
			}
			var menuStructure={"type":"datas","datas":datas,"fun":showObj};
    		var menu=$("#leftMenu").newMenu(menuStructure);
			menu.show();
		});
	};
	var tabs;
	function showObj(node){
		var obj={"title":node.text,"url":node.url};
		if(!tabs){
			tabs=$("#mainDiv").newTabs({"isClose":true,"tabList":[obj]});
		}else{
			tabs.add(obj);
		}
	}
	
	var TopDialog;
	function windowTopDialog(url,title,fun,parent){
		var dialogStruct={
				'display':url,
				'title':title,
				'buttons':[
				           {'text':'提交','action':function(){fun(TopDialog,parent);}},
				           {'text':'关闭','isClose':true,'action':function(){if(parent){parent.flushTable();}}}
				           ]
		};
		TopDialog =jyDialog(dialogStruct);
		TopDialog.open();
	}
	(function(){
		var moveBit=false;
		var isShrink=true;
		var srcx=0;
		//var srcy=0;
		var srcw=0;
		var srcl=0;
		//var srcl2=0;
		var leftObj=$("#leftMenu");
		var mainObj=$("#mainDiv");
		var moveLeft=$("#moveLeft");
		var leftDivW=leftObj.width()+10;
		var menuL=leftObj.offset().left;
		var moveW=moveLeft.width();
		moveLeft.bind("mouseover",function(ev, obj){
			//if(isShrink==true){
				$(this).addClass("mouseLeftOver");
			//}
		}).bind("mouseout",function(ev, obj){
			$(this).removeClass("mouseLeftOver");
		}).bind("mousedown",function(ev,obj){
			var obj = ev.srcElement || ev.target;
			if(obj.id=="moveLeft"){
				moveBit=true;
				$("#mask").show();
				//var obj = ev.srcElement || ev.target;
				srcx= moveLeft.offset().left;
		        srcw = leftObj.width();
		        srcl=mainObj.offset().left;
		        srcl2=moveLeft.offset().left;
			}
		}).bind("click",function(ev,obj){
			var obj = ev.srcElement || ev.target;
			var endObj=$(obj);
			if(obj.id=="shrinkIcon"){
				if(endObj.hasClass("shrinkIconLeft")){
					isShrink=true;
					endObj.removeClass("shrinkIconLeft");
					leftObj.css("width",(leftDivW-10)+"px");
		       	    moveLeft.css("left",leftDivW+menuL+"px");
		       	 	mainObj.css("left",(leftDivW+menuL+moveW)+"px");
				}else{
					isShrink=false;
					endObj.addClass("shrinkIconLeft");
					leftObj.css("width","0px");
		       	 	mainObj.css("left",(menuL+moveW)+10+"px");
		       	 	moveLeft.css("left",(menuL)+10+"px");
				}			
			}
		});
		$("#mask").bind("mouseup",function(ev, obj){
			moveBit=false;
			moveLeft.removeClass("mouseLeftOver");
			$("#mask").hide();
		}).bind("mousemove",function(ev,obj){
			if(moveBit&&isShrink){
				var obj = ev.srcElement || ev.target;
				var endx= jyTools.getOffsetLeft(ev,obj);
	       	 	var position= endx-srcx;
	       	 	leftDivW=(srcw+position);
	       	 	leftObj.css("width",leftDivW+"px");
	       	    moveLeft.css("left",(leftDivW+menuL+10)+"px");
	       	 	mainObj.css("left",(srcl+position)+"px");
			}
		});
	})();
	(function(){
		var mainTabs=[{"title":"工作台","url":"<%=basePath%>home/prepareExecute/welcome","isLock":true}];
		tabs=$("#mainDiv").newTabs({"isClose":true,"tabList":mainTabs});  		 
	})();
	
	function showMessage(message,time){
		$("").newMsg({}).show(message);
	}
	/**
	$(function(){		
		//是否有消息
		var sys = 'S001'
		jyAjax('<app:contextPath/>/sysMessage/queryMyMessage',{systemFlag:sys},function(result){
			if (result && result.status == 'ok') {
				var count = result.totalRows;
				$("#user_message_count").text("");
        		$("#user_message_count").text(count);
				var msgStructure={"waitTime":60000,"title":"系统新消息","type":"message","url":"<app:contextPath/>/sysMessage/queryMyMessage?systemFlag="+sys,"msgFun":function(obj){
						var param = {msgId:obj.id,systemFlag:sys};
					   jyAjax('<app:contextPath/>/sysMessage/updateMessageHasRead',param,function(result){
						   if(result && result.status == 'ok'){
							   jyDialog().alert(obj.conent);
						   }
					   });
				    	
				    }};
			 	var msgObj = $("").newMsg(msgStructure);
			}
		});
	});
	**/
    </script>
</body>
</html>
